using System;
using System.Collections.Generic;

[Serializable]
public class predescription_class
{
	public List<description_class> description;

	public string[] description_enum;

	public int description_position;

	public int layer_index;

	public int description_index;

	public predescription_class()
	{
		description = new List<description_class>();
		description.Add(new description_class());
		set_description_enum();
	}

	public void add_description(int description_number)
	{
		description.Insert(description_number, new description_class());
	}

	public void erase_description(int description_number)
	{
		if (description.Count > 1)
		{
			description.RemoveAt(description_number);
			set_description_enum();
			if (description_position > description_enum.Length - 1)
			{
				description_position = description_enum.Length - 1;
			}
		}
	}

	public void add_layer_index(int layer_number, int layer_index, int description_number)
	{
		move_layer_index(layer_number, 1);
		description[description_number].layer_index.Insert(layer_index, layer_number);
	}

	public void erase_layer_index(int layer_number, int layer_index, int description_number)
	{
		move_layer_index(layer_number, -1);
		description[description_number].layer_index.RemoveAt(layer_index);
	}

	public void move_layer_index(int layer_number, int direction)
	{
		for (int i = 0; i < description.Count; i++)
		{
			for (int j = 0; j < description[i].layer_index.Count; j++)
			{
				if (description[i].layer_index[j] >= layer_number)
				{
					description[i].layer_index[j] = description[i].layer_index[j] + direction;
				}
			}
		}
	}

	public void search_layer(int layer_number)
	{
		for (int i = 0; i < description.Count; i++)
		{
			for (int j = 0; j < description[i].layer_index.Count; j++)
			{
				if (description[i].layer_index[j] == layer_number)
				{
					description_index = i;
					layer_index = j;
					return;
				}
			}
		}
		description_index = -1;
		layer_index = -1;
	}

	public void set_description_enum()
	{
		description_enum = new string[description.Count];
		for (int i = 0; i < description.Count; i++)
		{
			description_enum[i] = description[i].text;
		}
	}
}
